package router

import (
	ctrl "a-admin/web/controller"
	midd "a-admin/web/middleware"

	"github.com/gofiber/fiber/v2"
)

func InitSysUserRoutes(r fiber.Router) {
	server := ctrl.NewSysUserController()
	r.Get("/profile/avatar/*", server.GetAvatar)
	rg := r.Group("/system/user")
	{
		rg.Put("/profile", midd.OperLogHandler("个人信息", midd.UPDATE), server.Edit)
		rg.Put("/profile/updatePwd", midd.OperLogHandler("个人信息", midd.UPDATE), server.UpdatePwd)
		rg.Post("/profile/avatar", server.Avatar)

		rg.Get("/", midd.PermsHandler("system:user:query"), server.Get)
		rg.Get("/list", midd.PermsHandler("system:user:list"), server.List)
		rg.Get("/:userId", midd.PermsHandler("system:user:query"), server.Get)
		rg.Post("", midd.PermsHandler("system:user:add"), midd.OperLogHandler("SYS", midd.UPDATE), server.Add)
		rg.Post("/export", midd.PermsHandler("system:user:export"), midd.OperLogHandler("SYS", midd.EXPORT), server.Export)
		rg.Post("/importTemplate", server.ImportTemplate)
		rg.Post("/importData", midd.PermsHandler("system:user:import"), midd.OperLogHandler("SYS", midd.IMPORT), server.ImportData)
		rg.Put("", midd.PermsHandler("system:user:edit"), midd.OperLogHandler("SYS", midd.UPDATE), server.Edit)
		rg.Put("/changeStatus", midd.PermsHandler("system:user:edit"), midd.OperLogHandler("SYS", midd.UPDATE), server.ChangeStatus)
		rg.Put("/resetPwd", midd.PermsHandler("system:user:edit"), midd.OperLogHandler("SYS", midd.UPDATE), server.ResetPwd)
		rg.Delete("/:ids", midd.PermsHandler("system:user:remove"), midd.OperLogHandler("SYS", midd.DELETE), server.Del)
	}
}
